<?php
    include 'base.php';

    // 定义字段
    $username = $_POST['username'];
    $password = $_POST['password'];

    // SQL
    $sql = "SELECT * FROM `user` WHERE `username`='$username' AND `password`='$password'";

    $res = $conn->query($sql);

    $row = mysqli_fetch_assoc($res);

    if ($row) {
        echo json_encode(array(
            "msg" => '登陆成功',
            "status" => true,
            "username" => $username,
            "token" => '92h92h239hf92h7823h2g6f2g27gfh'
        ));
    } else {
        echo json_encode(array(
            "msg" => '账户名或者密码错误',
            "code" => false,
            "token" => null
        ));
    }
?>